@extends('backend.layouts.app')

@section('title', $title = '提款申请')

@section('breadcrumb')
    <a href="">系统设置</a>
    <a href="">集成系统</a>
    <a href="">{{$title}}</a>
@endsection

@section('content')
    <div class="layui-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>{{$title}}</legend>
        </fieldset>
        <form class="layui-form layui-form-pane" method="GET"
              action="{{ route('agent.withdrawal.flow') }}">
            {{ csrf_field() }}
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">交易时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="created_at_start" name="created_at_start"
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               value="{{old('created_at_start',$params['created_at_start'])}}">
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="created_at_end" name="created_at_end"
                               placeholder="yyyy-MM-dd HH:mm:ss"
                               value="{{old('created_at_end',$params['created_at_end'])}}">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">交易单号</label>
                    <div class="layui-input-block">
                        <input type="text" name="transferid" width="200" autocomplete="off"
                               placeholder="请输入交易单号"
                               class="layui-input" value="{{old('transferid',$params['transferid'])}}">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">交易状态</label>
                    <div class="layui-input-block">
                        <select name="status" lay-verify="" lay-search="" lay-filter="status">
                            <option value="">请选择</option>
                            <option value=0 @if($params['status']===0) selected @endif>申请中</option>
                            <option value=1 @if($params['status']===1) selected @endif>审核通过</option>
                            <option value=-1 @if($params['status']===-1) selected @endif>注销申请</option>
                        </select>
                    </div>
                </div>
                @if(\Auth::user()->type==0)
                    <div class=" layui-inline">
                        <label class="layui-form-label">代理名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="agent_name" width="200" autocomplete="off"
                                   placeholder="请输入代理名称"
                                   class="layui-input" value="{{old('agent_name',$params['agent_name'])}}">
                        </div>
                    </div>
                @endif
                <button class=" layui-btn" lay-submit="" lay-filter="demo1">提交</button>
            </div>


        </form>


        <div class="layui-form">
            @if($withdrawalFlows->count())
                <table class="layui-table"
                       lay-data="{id:'DeleteTable',totalRow: true,limit:{{$limit+1}}}">
                    <thead>
                    <tr>
                        <th lay-data="{type:'checkbox', fixed: 'left'}">#</th>
                        <th lay-data="{field:'id', width:80, sort: true}">#</th>
                        <th lay-data="{field:'agent_name', width:100,  sort: true}">代理名称</th>
                        <th lay-data="{field:'pay_type', width:100,  sort: true}">支付方式</th>
                        <th lay-data="{field:'transferid', width:300,  sort: true}">交易号</th>
                        <th lay-data="{field:'account',  width:200, sort: true}">到账账户</th>
                        <th lay-data="{field:'account_address',width:200,  sort: true}">开户地址</th>
                        <th lay-data="{field:'account_real_name',width:100,  sort: true}">开户姓名</th>
                        <th lay-data="{field:'before_account_money',width:100,  sort: true, }">提款前余额</th>
                        <th lay-data="{field:'money',width:100,  sort: true}">提款金额</th>
                        <th lay-data="{field:'procedure_fee', width:100, sort: true}">手续费</th>
                        <th lay-data="{field:'to_account_money', width:100, sort: true}">到账金额</th>
                        <th lay-data="{field:'after_account_money', width:100, sort: true}">提款后余额</th>
                        <th lay-data="{field:'audit_account', width:100, sort: true}">审核账户</th>
                        <th lay-data="{field:'audit_at', width:170, sort: true}">审核时间</th>
                        <th lay-data="{field:'status', width:100, sort: true}">状态</th>
                        <th lay-data="{field:'created_at', width:170, sort: true}">创建时间</th>
                        <th lay-data="{field:'updated_at', width:170, sort: true}">修改时间</th>
                        <th lay-data="{field:'gj', width:150, sort: true}">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($withdrawalFlows as $index => $withdrawalFlow)
                        <tr>
                            <td></td>
                            <td>{{ $withdrawalFlow->id }}</td>
                            <td>{{ $withdrawalFlow->agent->name  }}</td>
                            <td>{{ config('administrator.pay_types')[$withdrawalFlow->pay_type]  }}</td>
                            <td>{{ $withdrawalFlow->transferid  }}</td>
                            <td>{{ $withdrawalFlow->account  }}</td>
                            <td>{{ $withdrawalFlow->account_address  }}</td>
                            <td>{{ $withdrawalFlow->account_real_name  }}</td>
                            <td>{{ $withdrawalFlow->before_account_money  }}</td>
                            <td>{{ $withdrawalFlow->money }}</td>
                            <td>{{ $withdrawalFlow->procedure_fee  }}</td>
                            <td>{{ $withdrawalFlow->to_account_money  }}</td>
                            <td>{{ $withdrawalFlow->after_account_money  }}</td>
                            <td>{{ $withdrawalFlow->auditor->name??''  }}</td>
                            <td>{{ $withdrawalFlow->audit_at  }}</td>
                            <td>{{ $withdrawalFlow->status_transform  }}</td>
                            <td>{{ $withdrawalFlow->created_at  }}</td>
                            <td>{{ $withdrawalFlow->updated_at  }}</td>
                            <td>
                                @if(\Auth::user()->type===0)
                                    @if($withdrawalFlow->status==0)
                                        <a href="{{route('agent.withdrawal.audit',[$withdrawalFlow->id])}}"
                                           class="layui-btn layui-btn-sm layui-btn-normal">通过</a>
                                    @endif
                                @endif
                                @if($withdrawalFlow->status==0)
                                    <a href="{{route('agent.withdrawal.cancel',[$withdrawalFlow->id])}}"
                                       class="layui-btn layui-btn-sm layui-btn-danger ">注销</a>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    <tr>
                        <td></td>
                        <td>总合计：</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>{{$sumParams['money']}}</td>
                        <td>{{$sumParams['procedure_fee']}}</td>
                        <td>{{$sumParams['to_account_money']}}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
                <div id="paginate-render"></div>
            @else
                <br/>
                <blockquote class="layui-elem-quote">暂无数据!</blockquote>
            @endif

        </div>
    </div>

@endsection

@section('scripts')
    @include('backend.layouts._paginate',[ 'count' => $withdrawalFlows->total(), 'delBatchUrl'=>'','limit'=>$limit])
    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //日期时间选择器
            laydate.render({
                elem: '#created_at_start'
                , type: 'datetime'
            });

            laydate.render({
                elem: '#created_at_end'
                , type: 'datetime'
            });
        });
    </script>
@endsection
